#pragma once

#include "common.h"

class ThreadCache
{
public:
    // 申请/释放内存对象
    void *Allocate(size_t size);
    void Deallocate(void *ptr, size_t size);
    // 从中心缓存获取内存对象
    void *FetchFromCentralCache(size_t index, size_t size);
    // 
    void ListTooLong(FreeList& list, size_t n);

private:
    FreeList _FreeList[NFREE_LIST];
};

#ifdef __linux__
    // Linux 特有的代码
    static thread_local ThreadCache* pTLSThreadCache = nullptr;
#else
    // 其他系统的代码 Win
    static _declspec(thread) ThreadCache* pTLSThreadCache = nullptr;
#endif

// Linux线程本地存储
// static thread_local ThreadCache* pTLSThreadCache = nullptr;


// Windows下线程存储
// static _declspec(thread) ThreadCache* pTLSThreadCache = nullptr;